/* 
 * File:   SerializarTest.cpp
 * Author: nahuel
 *
 * Created on Jun 9, 2013, 6:54:40 PM
 */

#include <stdlib.h>
#include <iostream>
#include "common_RepoItem.h"

/*
 * Simple C++ Test Suite
 */
using namespace::TP::Archivos;

using namespace TP::Archivos;

void testSerializar() {
    RepoItem repoItem;
    
    std::string filePath = "/home/someuser/au";
    std::string fileName = "file.txt";
    int version = 12;
    
    std::string hash1 = "hash1";
    std::string hash2 = "hash2";
    std::string hash3 = "hash3";
    
    repoItem.SetFilePath(filePath);
    repoItem.SetFilename(fileName);
    repoItem.SetVersion(version);
    
    repoItem.AddHash(hash1);
    repoItem.AddHash(hash2);
    repoItem.AddHash(hash3);
    
    string result = repoItem.Serializar();
    std::cout << result << std::endl;
    
    RepoItem* newRepoItem = RepoItem::Parse(result);
    
    if (
            (newRepoItem->GetCantidadHashes() != 3) ||
            (newRepoItem->GetFilePath() != filePath) ||
            (newRepoItem->GetFilename() != fileName) ||
            (newRepoItem->GetHash(0) != hash1) ||
            (newRepoItem->GetHash(1) != hash2) ||
            (newRepoItem->GetHash(2) != hash3) ||
            (newRepoItem->GetVersion() != version)       
       )
    {
        std::cout << "%TEST_FAILED% time=0 testname=testSerializar (SerializarTest) message=error message sample" << std::endl;
    }
}

int main(int argc, char** argv) {
    std::cout << "%SUITE_STARTING% SerializarTest" << std::endl;
    std::cout << "%SUITE_STARTED%" << std::endl;

    std::cout << "%TEST_STARTED% testSerializar (SerializarTest)" << std::endl;
    testSerializar();
    std::cout << "%TEST_FINISHED% time=0 testSerializar (SerializarTest)" << std::endl;

    std::cout << "%SUITE_FINISHED% time=0" << std::endl;

    return (EXIT_SUCCESS);
}

